<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta property="og:title" content="Docker安装Oracle 11g" />
<meta property="og:description" content="获取镜像 1 docker pull oracleinanutshell/oracle-xe-11g 创建容器 1 docker run -d -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true -e ORACLE_DISABLE_ASYNCH_IO=true -e ORACLE_ENABLE_XDB=true --restart=always --name oracle11g oracleinanutshell/oracle-xe-11g 镜像参数详情
1 2 3 4 5 6 7 8 // 端口映射 物理机端口:容器端口 -p 49161:1521 //是否支持远程登录 ORACLE_ALLOW_REMOTE //是否开启磁盘I/O ORACLE_DISABLE_ASYNCH_IO //是否创建默认用户XDB ORACLE_ENABLE_XDB 详细参数说明:https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g
数据库信息 hostname: localhostport: 49161sid: xeusername: systempassword: oracle 默认编码使用的是AL32UTF8，因为我的工作需要，需要改成ZHS16GBK
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 SQL&gt; select * from nls_database_parameters; PARAMETER	VALUE ------------------------------------------------------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- NLS_LANGUAGE	AMERICAN NLS_TERRITORY	AMERICA NLS_CURRENCY	$ NLS_ISO_CURRENCY	AMERICA NLS_NUMERIC_CHARACTERS	." />
<meta property="og:type" content="article" />
<meta property="og:url" content="http://wuju-i.gitee.io/post/docker%E5%AE%89%E8%A3%85oracle11g/" /><meta property="article:section" content="post" />
<meta property="article:published_time" content="2024-04-25T00:00:00+00:00" />
<meta property="article:modified_time" content="2024-04-25T00:00:00+00:00" />

  <meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Docker安装Oracle 11g"/>
<meta name="twitter:description" content="获取镜像 1 docker pull oracleinanutshell/oracle-xe-11g 创建容器 1 docker run -d -p 49161:1521 -e ORACLE_ALLOW_REMOTE=true -e ORACLE_DISABLE_ASYNCH_IO=true -e ORACLE_ENABLE_XDB=true --restart=always --name oracle11g oracleinanutshell/oracle-xe-11g 镜像参数详情
1 2 3 4 5 6 7 8 // 端口映射 物理机端口:容器端口 -p 49161:1521 //是否支持远程登录 ORACLE_ALLOW_REMOTE //是否开启磁盘I/O ORACLE_DISABLE_ASYNCH_IO //是否创建默认用户XDB ORACLE_ENABLE_XDB 详细参数说明:https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g
数据库信息 hostname: localhostport: 49161sid: xeusername: systempassword: oracle 默认编码使用的是AL32UTF8，因为我的工作需要，需要改成ZHS16GBK
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 SQL&gt; select * from nls_database_parameters; PARAMETER	VALUE ------------------------------------------------------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- NLS_LANGUAGE	AMERICAN NLS_TERRITORY	AMERICA NLS_CURRENCY	$ NLS_ISO_CURRENCY	AMERICA NLS_NUMERIC_CHARACTERS	."/>

  
  <meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff">
  <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#262d33">
  <title>
    
    橘子的博客 - Docker安装Oracle 11g
    
  </title>
  
  <link rel="shortcut icon" href="g.png" type="image/x-icon" />
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&display=swap"
    rel="stylesheet">
  
  
  
  <link rel="stylesheet" href="/minima.1714031344.css">

  
  
  <script defer type="text/javascript" src="/minima.1714031344.js"></script>
</head>
<script>
  
  let theme_2b_used = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';

  try {
    if (!('theme' in localStorage)) {
      const default_theme = '';
      
      
      if (default_theme === 'dark' || default_theme === 'light') {
        theme_2b_used = default_theme;
      }

      
      localStorage.theme = theme_2b_used;
    }
    
    document.querySelector('html').classList.add(localStorage.theme);
  } catch (e) {
    console.error(e);
  }
</script>


<body class=" sm:mx-5 sm:my-0">
  <header class="flex justify-between items-center mb-6 sm:my-3">
  <div class="flex items-center">
    
    <div id="theme-switcher" class="text-4xl cursor-pointer">🌑</div>
  </div>
  <nav class="flex items-center
    whitespace-nowrap overflow-x-auto overflow-y-hidden">
    
    <a class="ml-5" href="/">首页</a>
    
    <a class="ml-5" href="/categories">分类</a>
    
    <a class="ml-5" href="/log">日记</a>
    
    <a class="ml-5" href="/about">关于</a>
    
  </nav>
</header>
  
  

<h1 class="mt-6 mb-6">Docker安装Oracle 11g</h1>
<div class="mb-3 text-xs flex justify-between sm:flex-col">
	<div>
	
		Posted at &mdash; 24年 4月25日
	
		
	</div>
	
</div>
<main>
	<p></p>
	<article class="md">
		<h3 id="获取镜像">获取镜像</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">docker pull oracleinanutshell/oracle-xe-11g
</span></span></code></pre></td></tr></table>
</div>
</div><h3 id="创建容器">创建容器</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">docker run -d -p 49161:1521 -e <span class="nv">ORACLE_ALLOW_REMOTE</span><span class="o">=</span><span class="nb">true</span> -e <span class="nv">ORACLE_DISABLE_ASYNCH_IO</span><span class="o">=</span><span class="nb">true</span> -e <span class="nv">ORACLE_ENABLE_XDB</span><span class="o">=</span><span class="nb">true</span>  --restart<span class="o">=</span>always --name oracle11g oracleinanutshell/oracle-xe-11g
</span></span></code></pre></td></tr></table>
</div>
</div><p>镜像参数详情</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span><span class="lnt">7
</span><span class="lnt">8
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">// 端口映射  物理机端口:容器端口
</span></span><span class="line"><span class="cl">-p 49161:1521
</span></span><span class="line"><span class="cl">//是否支持远程登录
</span></span><span class="line"><span class="cl">ORACLE_ALLOW_REMOTE
</span></span><span class="line"><span class="cl">//是否开启磁盘I/O
</span></span><span class="line"><span class="cl">ORACLE_DISABLE_ASYNCH_IO
</span></span><span class="line"><span class="cl">//是否创建默认用户XDB
</span></span><span class="line"><span class="cl">ORACLE_ENABLE_XDB
</span></span></code></pre></td></tr></table>
</div>
</div><p>详细参数说明:https://hub.docker.com/r/oracleinanutshell/oracle-xe-11g</p>
<h3 id="数据库信息">数据库信息</h3>
<pre tabindex="0"><code>hostname: localhost
port: 49161
sid: xe
username: system
password: oracle
</code></pre><p>默认编码使用的是<code>AL32UTF8</code>，因为我的工作需要，需要改成<code>ZHS16GBK</code></p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">SQL</span><span class="o">&gt;</span><span class="w"> </span><span class="k">select</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">nls_database_parameters</span><span class="p">;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="k">PARAMETER</span><span class="w">						     </span><span class="n">VALUE</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="c1">------------------------------------------------------------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">NLS_LANGUAGE</span><span class="w">						     </span><span class="n">AMERICAN</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_TERRITORY</span><span class="w">						     </span><span class="n">AMERICA</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_CURRENCY</span><span class="w">						     </span><span class="err">$</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_ISO_CURRENCY</span><span class="w">					     </span><span class="n">AMERICA</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_NUMERIC_CHARACTERS</span><span class="w">					     </span><span class="p">.,</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_CHARACTERSET</span><span class="w">					     </span><span class="n">AL32UTF8</span><span class="w">            </span><span class="c1">-------------数据库字符集
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">NLS_CALENDAR</span><span class="w">						     </span><span class="n">GREGORIAN</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_DATE_FORMAT</span><span class="w"> 					     </span><span class="n">DD</span><span class="o">-</span><span class="n">MON</span><span class="o">-</span><span class="n">RR</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_DATE_LANGUAGE</span><span class="w">					     </span><span class="n">AMERICAN</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_SORT</span><span class="w">						     </span><span class="nb">BINARY</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_TIME_FORMAT</span><span class="w"> 					     </span><span class="n">HH</span><span class="p">.</span><span class="n">MI</span><span class="p">.</span><span class="n">SSXFF</span><span class="w"> </span><span class="n">AM</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_TIMESTAMP_FORMAT</span><span class="w">				                      </span><span class="n">DD</span><span class="o">-</span><span class="n">MON</span><span class="o">-</span><span class="n">RR</span><span class="w"> </span><span class="n">HH</span><span class="p">.</span><span class="n">MI</span><span class="p">.</span><span class="n">SSXFF</span><span class="w"> </span><span class="n">AM</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_TIME_TZ_FORMAT</span><span class="w">					     </span><span class="n">HH</span><span class="p">.</span><span class="n">MI</span><span class="p">.</span><span class="n">SSXFF</span><span class="w"> </span><span class="n">AM</span><span class="w"> </span><span class="n">TZR</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_TIMESTAMP_TZ_FORMAT</span><span class="w"> 				     </span><span class="n">DD</span><span class="o">-</span><span class="n">MON</span><span class="o">-</span><span class="n">RR</span><span class="w"> </span><span class="n">HH</span><span class="p">.</span><span class="n">MI</span><span class="p">.</span><span class="n">SSXFF</span><span class="w"> </span><span class="n">AM</span><span class="w"> </span><span class="n">TZR</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_DUAL_CURRENCY</span><span class="w">					     </span><span class="err">$</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_COMP</span><span class="w">						     </span><span class="nb">BINARY</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_LENGTH_SEMANTICS</span><span class="w">				                      </span><span class="n">BYTE</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_NCHAR_CONV_EXCP</span><span class="w">				                     </span><span class="k">FALSE</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">NLS_NCHAR_CHARACTERSET</span><span class="w">				    </span><span class="n">AL16UTF16</span><span class="w">          </span><span class="c1">---------------------国家字符集（用的少）
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">NLS_RDBMS_VERSION</span><span class="w">					     </span><span class="mi">11</span><span class="p">.</span><span class="mi">2</span><span class="p">.</span><span class="mi">0</span><span class="p">.</span><span class="mi">1</span><span class="p">.</span><span class="mi">0</span><span class="w">
</span></span></span></code></pre></td></tr></table>
</div>
</div><div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt"> 1
</span><span class="lnt"> 2
</span><span class="lnt"> 3
</span><span class="lnt"> 4
</span><span class="lnt"> 5
</span><span class="lnt"> 6
</span><span class="lnt"> 7
</span><span class="lnt"> 8
</span><span class="lnt"> 9
</span><span class="lnt">10
</span><span class="lnt">11
</span><span class="lnt">12
</span><span class="lnt">13
</span><span class="lnt">14
</span><span class="lnt">15
</span><span class="lnt">16
</span><span class="lnt">17
</span><span class="lnt">18
</span><span class="lnt">19
</span><span class="lnt">20
</span><span class="lnt">21
</span><span class="lnt">22
</span><span class="lnt">23
</span><span class="lnt">24
</span><span class="lnt">25
</span><span class="lnt">26
</span><span class="lnt">27
</span><span class="lnt">28
</span><span class="lnt">29
</span><span class="lnt">30
</span><span class="lnt">31
</span><span class="lnt">32
</span><span class="lnt">33
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl"><span class="c1"># 进入docker容器的bash</span>
</span></span><span class="line"><span class="cl">docker <span class="nb">exec</span> -i -t XXXX /bin/bash
</span></span><span class="line"><span class="cl"><span class="c1"># 切换oracle用户</span>
</span></span><span class="line"><span class="cl">su oracle
</span></span><span class="line"><span class="cl"><span class="c1"># 声明实例名称</span>
</span></span><span class="line"><span class="cl"><span class="nb">export</span> <span class="nv">ORACLE_SID</span><span class="o">=</span>xe
</span></span><span class="line"><span class="cl"><span class="c1"># 使用sysdba登录sqlplus</span>
</span></span><span class="line"><span class="cl">sqlplus <span class="s2">&#34;/as sysdba&#34;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 先关闭数据库实例</span>
</span></span><span class="line"><span class="cl">SHUTDOWN IMMEDIATE<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1">#  打开控制文件</span>
</span></span><span class="line"><span class="cl">STARTUP MOUNT<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 开启限制会话模式</span>
</span></span><span class="line"><span class="cl">ALTER SYSTEM ENABLE RESTRICTED SESSION<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># ALTER SYSTEM DISABLE RESTRICTED SESSION;  取消限制会话模式</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 设定job队列可以启动的进程数</span>
</span></span><span class="line"><span class="cl">ALTER SYSTEM SET <span class="nv">JOB_QUEUE_PROCESSES</span><span class="o">=</span>0<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 禁用队列监视器协调器</span>
</span></span><span class="line"><span class="cl">ALTER SYSTEM SET <span class="nv">AQ_TM_PROCESSES</span><span class="o">=</span>0<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 修改并打开数据库</span>
</span></span><span class="line"><span class="cl">ALTER DATABASE OPEN<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 修改数据库字符集</span>
</span></span><span class="line"><span class="cl">ALTER DATABASE CHARACTER SET ZHS16GBK<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 当提示我们：新字符集必须为旧字符集的超集合，使用以下命令：</span>
</span></span><span class="line"><span class="cl">ALTER DATABASE CHARACTER SET INTERNAL_USE ZHS16GBK<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 查看参数列表</span>
</span></span><span class="line"><span class="cl"><span class="k">select</span> * from v<span class="nv">$nls_parameters</span><span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 设置完成后，关闭数据库</span>
</span></span><span class="line"><span class="cl">SHUTDOWN IMMEDIATE<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 再次打开数据库</span>
</span></span><span class="line"><span class="cl">STARTUP OPEN<span class="p">;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># 这时我们再使用之前的方式查看字符集</span>
</span></span><span class="line"><span class="cl"><span class="k">select</span> userenv<span class="o">(</span><span class="s1">&#39;language&#39;</span><span class="o">)</span> from dual<span class="p">;</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>数据库的字符集就改为了<code>CHINESE_CHINA.ZHS16GBK</code>。</p>
<h3 id="数据库备份导入">数据库备份导入</h3>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">expdp <span class="nv">dumpfile</span><span class="o">=</span>xxx.dmp <span class="nv">logfile</span><span class="o">=</span>xxx.log <span class="nv">full</span><span class="o">=</span>y
</span></span></code></pre></td></tr></table>
</div>
</div>
	</article>
</main>





	

	

	



  <footer class="mt-8 flex sm:flex-col-reverse justify-between items-center">
  <p class="mt-0 text-sm">
    © 2022 | 橘子
    
  </p>
  <p class="flex items-center mt-0">
    
  </p>
</footer>
</body>
</html>